home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / editdemo / vbinput.bas < prev   
Encoding:
BASIC Source File  |  1995-05-09  |  21.0 KB  |  727 lines

  1. '(c) 1991 by Keith Milligan
  2. '            100 Lee Road 605
  3. '            Smiths, AL 36877
  4. '            205-291-9712 Home
  5. '            205-298-1974 Work
  6. '            Compuserve ID = 70645,520
  7.  
  8. 'Use these routines if they will help you.  You can use,
  9. 'modify, copy, or distribute with a clear concience.
  10.  
  11. 'Visual Basic 1.0 input routines
  12.  
  13. 'These routine are use two events for each text control.
  14. 'There is a Sub for the KeyPress event and a corresponding
  15. 'Function for the LostFocus Event.  The KeyPress (KP) routine
  16. 'restricts certain keystrokes and the LostFocus (LF) routine
  17. 'validates the data entered in the text control and assigns
  18. 'the entered data to a variable.
  19.  
  20. 'Date
  21. '  Sub DateKP(ThisControl, KeyAscii)
  22. '  Function  DateLF$(ThisControl, EarliestDate$)
  23. '  Format of EarliestDate$ is "yymmdd".
  24. '  Accepts date enter in one of the following formats:
  25. '     60491, 060491, 06/04/91, or 6/4/91
  26. '  Returns date in the format 910604.
  27.  
  28. 'MultPrice
  29. '  Sub MultPriceKP(ThisControl, KeyAscii)
  30. '  Function MultPriceLF$(ThisControl)
  31. '  Used to accept retail prices.  For example 3 for $1.00.
  32. '  Accepts and returns in the following formats:
  33. '    Input          Returns
  34. '     149           01/01.49
  35. '     1.49          01/01.49
  36. '     3/49          03/00.49
  37. '     3/.49         03/00.49
  38.  
  39. 'Point2
  40. '  Sub Point2KP(ThisControl, Length%, KeyAscii)
  41. '  Function Point2LF(ThisControl, Min#, Max#)
  42. '  Accepts number with two digits to the right of the decimal point.
  43. '  Maximum length = Length%
  44. '  Minimum value = Min#
  45. '  Maximum value = Max#
  46. '  Example 123.49
  47.  
  48. 'Point4
  49. '  Sub Point4KP(ThisControl, Length%, KeyAscii)
  50. '  Function Point4LF(ThisControl, Min#, Max#)
  51. '  Accepts number with four digits to the right of the decimal point.
  52. '  Maximum length = Length%
  53. '  Minimum value = Min#
  54. '  Maximum value = Max#
  55. '  Example 123.4978
  56.  
  57. 'Str
  58. '  Sub StrKP(ThisControl, Length%, KeyAscii)
  59. '  No LF function for this routine just move text to string in
  60. '    LostFocus Event.
  61. '  Accepts string of length less than or equal to Length%.
  62.  
  63. 'UCStr
  64. '  Sub UCStrKP(ThisControl, Length%, KeyAscii)
  65. '  No LF function for this routine just move text to string in
  66. '    LostFocus Event.
  67. '  Accepts string of length less than or equal to Length%.
  68. '  Converts characters to upper case as typed.
  69.  
  70. 'Long
  71. '  Sub LongKP(ThisControl, Length%, KeyAscii)
  72. '  Function LongLF&(ThisControl, Min&, Max&)
  73. '  Accepts long integer amount.
  74.  
  75. 'Int
  76. '  Sub IntKP(ThisControl, Length%, KeyAscii)
  77. '  Function IntLF%(ThisControl, Min%, Max%)
  78. '  Same as Long but accepts normal integer amounts
  79.  
  80. 'Curr2
  81. '  Sub Curr2KP(ThisControl, Length%, KeyAscii)
  82. '  Function Curr2LF@(ThisControl, Min@, Max@)
  83. '  Same as Point2 but for currency data type.
  84.  
  85. 'Curr4
  86. '  Sub Curr4KP(ThisControl, Length%, KeyAscii)
  87. '  Function Curr4LF(ThisControl, Min@, Max@)
  88. '  Same as Point4 but for currency data type.
  89.  
  90. 'DateSer
  91. '  Sub DateSerKP(Thiscontrol, KeyAscii)
  92. '  Function DateSerLF@(ThisControl, EarliestDate$)
  93. '  Same as Date but returns date serial number instead of yymmdd.
  94.  
  95. '
  96.  
  97. Sub Curr2KP (ThisControl As Control, Length%, KeyAscii As Integer)
  98.     If Len(ThisControl.Text) = Length% Then
  99.       If KeyAscii <> 8 Then
  100.         KeyAscii = 0
  101.         Beep
  102.       End If
  103.     Else
  104.       C$ = Chr$(KeyAscii)
  105.       StringLength% = Len(ThisControl.Text)
  106.       DecimalPosition% = InStr(ThisControl.Text, ".")
  107.       If StringLength% - DecimalPosition% = 2 And DecimalPosition% <> 0 Then
  108.         If ThisControl.SelStart < DecimalPosition% Then
  109.           Select Case C$
  110.             Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  111.             Case "-"
  112.               If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  113.                 KeyAscii = 0
  114.                 Beep
  115.               End If
  116.             Case Else
  117.               KeyAscii = 0
  118.               Beep
  119.           End Select
  120.         ElseIf KeyAscii <> 8 Then
  121.           KeyAscii = 0
  122.           Beep
  123.         End If
  124.       Else
  125.         Select Case C$
  126.           Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  127.           Case "."
  128.             If InStr(ThisControl.Text, ".") <> 0 Then
  129.               KeyAscii = 0
  130.               Beep
  131.             End If
  132.           Case "-"
  133.             If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  134.               KeyAscii = 0
  135.               Beep
  136.             End If
  137.           Case Else
  138.             KeyAscii = 0
  139.             Beep
  140.         End Select
  141.       End If
  142.     End If
  143. End Sub
  144.  
  145. Function Curr2LF@ (ThisControl As Control, Min@, Max@)
  146.   Test@ = Val(ThisControl.Text)
  147.   If ThisControl.Text <> "" Then
  148.     If Test@ < Min@ Or Test@ > Max@ Then
  149.       Beep
  150.       Msg$ = "Number must be between " + Str$(Min@) + " and " + Str$(Max@)
  151.       MsgBox Msg$, 0, "Warning"
  152.       ThisControl.SetFocus
  153.     Else
  154.       Curr2LF@ = Test@
  155.     End If
  156.   End If
  157.  
  158. End Function
  159.  
  160. Sub Curr4KP (ThisControl As Control, Length%, KeyAscii As Integer)
  161.     If Len(ThisControl.Text) = Length% Then
  162.       If KeyAscii <> 8 Then
  163.         KeyAscii = 0
  164.         Beep
  165.       End If
  166.     Else
  167.       C$ = Chr$(KeyAscii)
  168.       StringLength% = Len(ThisControl.Text)
  169.       DecimalPosition% = InStr(ThisControl.Text, ".")
  170.       If StringLength% - DecimalPosition% = 4 And DecimalPosition% <> 0 Then
  171.         If ThisControl.SelStart < DecimalPosition% Then
  172.           Select Case C$
  173.             Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  174.             Case "-"
  175.               If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  176.                 KeyAscii = 0
  177.                 Beep
  178.               End If
  179.             Case Else
  180.               KeyAscii = 0
  181.               Beep
  182.           End Select
  183.         ElseIf KeyAscii <> 8 Then
  184.           KeyAscii = 0
  185.           Beep
  186.         End If
  187.       Else
  188.         Select Case C$
  189.           Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  190.           Case "."
  191.             If InStr(ThisControl.Text, ".") <> 0 Then
  192.               KeyAscii = 0
  193.               Beep
  194.             End If
  195.           Case "-"
  196.             If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  197.               KeyAscii = 0
  198.               Beep
  199.             End If
  200.           Case Else
  201.             KeyAscii = 0
  202.             Beep
  203.         End Select
  204.       End If
  205.     End If
  206. End Sub
  207.  
  208. Function Curr4LF (ThisControl As Control, Min@, Max@)
  209.   Test@ = Val(ThisControl.Text)
  210.   If ThisControl.Text <> "" Then
  211.     If Test@ < Min@ Or Test@ > Max@ Then
  212.       Beep
  213.       Msg$ = "Number must be between " + Str$(Min@) + " and " + Str$(Max@)
  214.       MsgBox Msg$, 0, "Warning"
  215.       ThisControl.SetFocus
  216.     Else
  217.       Curr4LF! = Test@
  218.     End If
  219.   End If
  220.  
  221. End Function
  222.  
  223. Sub DateKP (ThisControl As Control, KeyAscii As Integer)
  224.     C$ = Chr$(KeyAscii)
  225.     Test$ = ThisControl.Text
  226.     If Len(Test$) = 6 And InStr(Test$, "/") = 0 Then
  227.       If KeyAscii <> 8 Then
  228.         KeyAscii = 0
  229.         Beep
  230.       End If
  231.     ElseIf Len(Test$) = 8 And InStr(Test$, "/") <> 0 Then
  232.       If KeyAscii <> 8 Then
  233.         KeyAscii = 0
  234.         Beep
  235.       End If
  236.     Else
  237.         Select Case C$
  238.           Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8), "/"
  239.           Case Else
  240.             KeyAscii = 0
  241.             Beep
  242.         End Select
  243.     End If
  244. End Sub
  245.  
  246. Function DateLF$ (ThisControl As Control, EarliestDate$)
  247.   If ThisControl.Text <> "" Then
  248.     BadDate$ = "N"
  249.     InDate$ = ThisControl.Text
  250.     If Len(InDate$) = 5 Then
  251.       InDate$ = "0" + InDate$
  252.     ElseIf Len(InDate$) = 6 Then
  253.       If InStr(InDate$, "/") <> 0 Then
  254.         InDate$ = "0" + Left$(InDate$, 1) + "0" + Mid$(InDate$, 3, 1) + Mid$(InDate$, 5, 2)
  255.       End If
  256.     ElseIf Len(InDate$) = 7 Then
  257.       If Mid$(InDate$, 2, 1) = "/" Then
  258.         InDate$ = "0" + Left$(InDate$, 1) + Mid$(InDate$, 3, 2) + Mid$(InDate$, 6, 2)
  259.       Else
  260.         InDate$ = Left$(InDate$, 2) + "0" + Mid$(InDate$, 4, 1) + Mid$(InDate$, 6, 2)
  261.       End If
  262.     ElseIf Len(InDate$) = 8 Then
  263.       InDate$ = Left$(InDate$, 2) + Mid$(InDate$, 4, 2) + Mid$(InDate$, 7, 2)
  264.     Else
  265.       BadDate$ = "Y"
  266.     End If
  267.     If InStr(InDate$, "/") = 0 And BadDate$ = "N" Then
  268.       Months% = Val(Left$(InDate$, 2))
  269.       Days% = Val(Mid$(InDate$, 3, 2))
  270.       Select Case Months%
  271.         Case 1, 3, 5, 7, 8, 10, 12
  272.           If Days% < 1 Or Days% > 31 Then
  273.             BadDate$ = "Y"
  274.           End If
  275.         Case 4, 6, 9, 11
  276.           If Days% < 1 Or Days% > 30 Then
  277.             BadDate$ = "Y"
  278.           End If
  279.         Case 2
  280.           If Days% < 1 Or Days% > 29 Then
  281.              BadDate$ = "Y"
  282.           End If
  283.         Case Else
  284.           BadDate$ = "Y"
  285.       End Select
  286.     End If
  287.     InDate$ = Mid$(InDate$, 5, 2) + Left$(InDate$, 4)
  288.     If InDate$ < EarliestDate$ And Left$(InDate$, 2) > "30" Then
  289.       BadDate$ = "Y"
  290.     End If
  291.     If BadDate$ = "Y" Then
  292.       Beep
  293.       Msg$ = "Not a valid date."
  294.       MsgBox Msg$, 0, "Warning"
  295.       ThisControl.SetFocus
  296.     Else
  297.       If Left$(InDate$, 2) > "20" Then
  298.         InDate$ = "19" + InDate$
  299.       Else
  300.         InDate$ = "20" + InDate$
  301.       End If
  302.       Temp# = DateSerial(Val(Left$(InDate$, 4)), Val(Mid$(InDate$, 5, 2)), Val(Mid$(InDate$, 7, 2)))
  303.       ThisControl.Text = Format$(Temp#, "mm/dd/yy")
  304.       Temp2$ = ThisControl.Text
  305.       DateLF$ = Right$(Temp2$, 2) + Left$(Temp2$, 2) + Mid$(Temp2$, 4, 2)
  306.     End If
  307.   End If
  308. End Function
  309.  
  310. Sub DateSerKP (ThisControl As Control, KeyAscii As Integer)
  311.     C$ = Chr$(KeyAscii)
  312.     Test$ = ThisControl.Text
  313.     If Len(Test$) = 6 And InStr(Test$, "/") = 0 Then
  314.       If KeyAscii <> 8 Then
  315.         KeyAscii = 0
  316.         Beep
  317.       End If
  318.     ElseIf Len(Test$) = 8 And InStr(Test$, "/") <> 0 Then
  319.       If KeyAscii <> 8 Then
  320.         KeyAscii = 0
  321.         Beep
  322.       End If
  323.     Else
  324.         Select Case C$
  325.           Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8), "/"
  326.           Case Else
  327.             KeyAscii = 0
  328.             Beep
  329.         End Select
  330.     End If
  331. End Sub
  332.  
  333. Function DateSerLF# (ThisControl As Control, EarliestDate$)
  334.   If ThisControl.Text <> "" Then
  335.     BadDate$ = "N"
  336.     InDate$ = ThisControl.Text
  337.     If Len(InDate$) = 5 Then
  338.       InDate$ = "0" + InDate$
  339.     ElseIf Len(InDate$) = 6 Then
  340.       If InStr(InDate$, "/") <> 0 Then
  341.         InDate$ = "0" + Left$(InDate$, 1) + "0" + Mid$(InDate$, 3, 1) + Mid$(InDate$, 5, 2)
  342.       End If
  343.     ElseIf Len(InDate$) = 7 Then
  344.       If Mid$(InDate$, 2, 1) = "/" Then
  345.         InDate$ = "0" + Left$(InDate$, 1) + Mid$(InDate$, 3, 2) + Mid$(InDate$, 6, 2)
  346.       Else
  347.         InDate$ = Left$(InDate$, 2) + "0" + Mid$(InDate$, 4, 1) + Mid$(InDate$, 6, 2)
  348.       End If
  349.     ElseIf Len(InDate$) = 8 Then
  350.       InDate$ = Left$(InDate$, 2) + Mid$(InDate$, 4, 2) + Mid$(InDate$, 7, 2)
  351.     Else
  352.       BadDate$ = "Y"
  353.     End If
  354.     If InStr(InDate$, "/") = 0 And BadDate$ = "N" Then
  355.       Months% = Val(Left$(InDate$, 2))
  356.       Days% = Val(Mid$(InDate$, 3, 2))
  357.       Select Case Months%
  358.         Case 1, 3, 5, 7, 8, 10, 12
  359.           If Days% < 1 Or Days% > 31 Then
  360.             BadDate$ = "Y"
  361.           End If
  362.         Case 4, 6, 9, 11
  363.           If Days% < 1 Or Days% > 30 Then
  364.             BadDate$ = "Y"
  365.           End If
  366.         Case 2
  367.           If Days% < 1 Or Days% > 29 Then
  368.              BadDate$ = "Y"
  369.           End If
  370.         Case Else
  371.           BadDate$ = "Y"
  372.       End Select
  373.     End If
  374.     InDate$ = Mid$(InDate$, 5, 2) + Left$(InDate$, 4)
  375.     If InDate$ < EarliestDate$ And Left$(InDate$, 2) > "30" Then
  376.       BadDate$ = "Y"
  377.     End If
  378.     If BadDate$ = "Y" Then
  379.       Beep
  380.       Msg$ = "Not a valid date."
  381.       MsgBox Msg$, 0, "Warning"
  382.       ThisControl.SetFocus
  383.     Else
  384.       If Left$(InDate$, 2) > "20" Then
  385.         InDate$ = "19" + InDate$
  386.       Else
  387.         InDate$ = "20" + InDate$
  388.       End If
  389.       Temp# = DateSerial(Val(Left$(InDate$, 4)), Val(Mid$(InDate$, 5, 2)), Val(Mid$(InDate$, 7, 2)))
  390.       DateSerLF# = Temp#
  391.       ThisControl.Text = Format$(Temp#, "mm/dd/yy")
  392.     End If
  393.   End If
  394.  
  395. End Function
  396.  
  397. Sub IntKP (ThisControl As Control, Length%, KeyAscii As Integer)
  398.     If Len(ThisControl.Text) = Length% Then
  399.       If KeyAscii <> 8 Then
  400.         KeyAscii = 0
  401.         Beep
  402.       End If
  403.     Else
  404.       C$ = Chr$(KeyAscii)
  405.       Select Case C$
  406.         Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  407.         Case "-"
  408.           If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  409.             KeyAscii = 0
  410.             Beep
  411.           End If
  412.         Case Else
  413.           KeyAscii = 0
  414.           Beep
  415.       End Select
  416.     End If
  417. End Sub
  418.  
  419. Function IntLF (ThisControl As Control, Min%, Max%)
  420.   On Local Error GoTo ErrorHandler
  421.   Test% = Val(ThisControl.Text)
  422.   If ThisControl.Text <> "" Then
  423.     If Test% < Min% Or Test% > Max% Then
  424.       Beep
  425.       Msg$ = "Number must be between " + Str$(Min%) + " and " + Str$(Max%)
  426.       MsgBox Msg$, 0, "Warning"
  427.       ThisControl.SetFocus
  428.     Else
  429.       IntLF! = Test%
  430.     End If
  431.   End If
  432.   Exit Function
  433. ErrorHandler:
  434.   Beep
  435.   Msg$ = "The number must be a valid integer amount."
  436.   MsgBox Msg$, 0, "Warning"
  437.   ThisControl.SetFocus
  438.   Resume EndErrorHandler
  439. EndErrorHandler:
  440. End Function
  441.  
  442. Sub LongKP (ThisControl As Control, Length%, KeyAscii As Integer)
  443.     If Len(ThisControl.Text) = Length% Then
  444.       If KeyAscii <> 8 Then
  445.         KeyAscii = 0
  446.         Beep
  447.       End If
  448.     Else
  449.       C$ = Chr$(KeyAscii)
  450.       Select Case C$
  451.         Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  452.         Case "-"
  453.           If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  454.             KeyAscii = 0
  455.             Beep
  456.           End If
  457.         Case Else
  458.           KeyAscii = 0
  459.           Beep
  460.       End Select
  461.     End If
  462. End Sub
  463.  
  464. Function LongLF& (ThisControl As Control, Min&, Max&)
  465.   On Local Error GoTo ErrorHandler2
  466.   Test& = Val(ThisControl.Text)
  467.   If ThisControl.Text <> "" Then
  468.     If Test& < Min& Or Test& > Max& Then
  469.       Beep
  470.       Msg$ = "Number must be between " + Str$(Min&) + " and " + Str$(Max&)
  471.       MsgBox Msg$, 0, "Warning"
  472.       ThisControl.SetFocus
  473.     Else
  474.       LongLF& = Test&
  475.     End If
  476.   End If
  477.   Exit Function
  478. ErrorHandler2:
  479.   Beep
  480.   Msg$ = "The number must be a valid long integer amount."
  481.   MsgBox Msg$, 0, "Warning"
  482.   ThisControl.SetFocus
  483.   Resume EndErrorHandler2
  484. EndErrorHandler2:
  485. End Function
  486.  
  487. Sub MultPriceKP (ThisControl As Control, KeyAscii As Integer)
  488.     C$ = Chr$(KeyAscii)
  489.     Test$ = ThisControl.Text
  490.     If Len(Test$) = 5 And InStr(Test$, "/") = 0 Then
  491.       If KeyAscii <> 8 Then
  492.         KeyAscii = 0
  493.         Beep
  494.       End If
  495.     ElseIf Len(Test$) = 8 And InStr(Test$, "/") <> 0 Then
  496.       If KeyAscii <> 8 Then
  497.         KeyAscii = 0
  498.         Beep
  499.       End If
  500.     Else
  501.       StringLength% = Len(ThisControl.Text)
  502.       DecimalPosition% = InStr(ThisControl.Text, ".")
  503.       If StringLength% - DecimalPosition% = 2 And DecimalPosition% <> 0 Then
  504.         If KeyAscii <> 8 Then
  505.           KeyAscii = 0
  506.           Beep
  507.         End If
  508.       Else
  509.         Select Case C$
  510.           Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  511.           Case "."
  512.             If InStr(ThisControl.Text, ".") <> 0 Then
  513.               KeyAscii = 0
  514.               Beep
  515.             End If
  516.           Case "/"
  517.             If InStr(ThisControl.Text, "/") <> 0 Or InStr(ThisControl.Text, ".") <> 0 Then
  518.               KeyAscii = 0
  519.               Beep
  520.             End If
  521.           Case Else
  522.             KeyAscii = 0
  523.             Beep
  524.         End Select
  525.       End If
  526.     End If
  527. End Sub
  528.  
  529. Function MultPriceLF$ (ThisControl As Control)
  530.   If Len(ThisControl.Text) <> 0 Then
  531.     BadQuantity$ = "N"
  532.     BadAmount$ = "N"
  533.     Temp$ = ThisControl.Text
  534.     If InStr(Temp$, "/") = 0 Then
  535.       Qty$ = "01"
  536.       Amt$ = Temp$
  537.     Else
  538.       Qty$ = Left$(Temp$, InStr(Temp$, "/") - 1)
  539.       Amt$ = Right$(Temp$, Len(Temp$) - InStr(Temp$, "/"))
  540.     End If
  541.     QtyLength% = Len(Qty$)
  542.     Select Case QtyLength%
  543.       Case 1
  544.         Qty$ = "0" + Qty$
  545.       Case 2
  546.       Case Else
  547.         BadQuantity$ = "Y"
  548.     End Select
  549.     If InStr(Amt$, ".") = 0 Then
  550.       Amt$ = Left$(Amt$, Len(Amt$) - 2) + "." + Right$(Amt$, 2)
  551.     End If
  552.     If InStr(Amt$, ".") = Len(Amt$) - 1 Then
  553.       Amt$ = Amt$ + "0"
  554.     End If
  555.     If InStr(Amt$, ".") = Len(Amt$) Then
  556.       Amt$ = Amt$ + "00"
  557.     End If
  558.     Amt$ = String$(5 - Len(Amt$), "0") + Amt$
  559.     If Val(Amt$) > 99.99 Or Val(Amt$) < .01 Then
  560.       BadAmount$ = "Y"
  561.     End If
  562.     If Val(Qty$) > 99 Or Val(Qty$) < 1 Then
  563.       BadQuantity$ = "Y"
  564.     End If
  565.     If BadAmount$ = "Y" Then
  566.       Beep
  567.       Msg$ = "Price is not valid."
  568.       MsgBox Msg$, 0, "Warning"
  569.       ThisControl.SetFocus
  570.     ElseIf BadQuantity$ = "Y" Then
  571.       Beep
  572.       Msg$ = "Quantity is not valid."
  573.       MsgBox Msg$, 0, "Warning"
  574.       ThisControl.SetFocus
  575.     Else
  576.       ThisControl.Text = Qty$ + "/" + Amt$
  577.       MultPriceLF$ = ThisControl.Text
  578.     End If
  579.   End If
  580. End Function
  581.  
  582. Sub Point2KP (ThisControl As Control, Length%, KeyAscii As Integer)
  583.     If Len(ThisControl.Text) = Length% Then
  584.       If KeyAscii <> 8 Then
  585.         KeyAscii = 0
  586.         Beep
  587.       End If
  588.     Else
  589.       C$ = Chr$(KeyAscii)
  590.       StringLength% = Len(ThisControl.Text)
  591.       DecimalPosition% = InStr(ThisControl.Text, ".")
  592.       If StringLength% - DecimalPosition% = 2 And DecimalPosition% <> 0 Then
  593.         If ThisControl.SelStart < DecimalPosition% Then
  594.           Select Case C$
  595.             Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  596.             Case "-"
  597.               If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  598.                 KeyAscii = 0
  599.                 Beep
  600.               End If
  601.             Case Else
  602.               KeyAscii = 0
  603.               Beep
  604.           End Select
  605.         ElseIf KeyAscii <> 8 Then
  606.           KeyAscii = 0
  607.           Beep
  608.         End If
  609.       Else
  610.         Select Case C$
  611.           Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  612.           Case "."
  613.             If InStr(ThisControl.Text, ".") <> 0 Then
  614.               KeyAscii = 0
  615.               Beep
  616.             End If
  617.           Case "-"
  618.             If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  619.               KeyAscii = 0
  620.               Beep
  621.             End If
  622.           Case Else
  623.             KeyAscii = 0
  624.             Beep
  625.         End Select
  626.       End If
  627.     End If
  628. End Sub
  629.  
  630. Function Point2LF# (ThisControl As Control, Min#, Max#)
  631.   Test# = Val(ThisControl.Text)
  632.   If ThisControl.Text <> "" Then
  633.     If Test# < Min# Or Test# > Max# Then
  634.       Beep
  635.       Msg$ = "Number must be between " + Str$(Min#) + " and " + Str$(Max#)
  636.       MsgBox Msg$, 0, "Warning"
  637.       ThisControl.SetFocus
  638.     Else
  639.       Point2LF# = Test#
  640.     End If
  641.   End If
  642. End Function
  643.  
  644. Sub Point4KP (ThisControl As Control, Length%, KeyAscii As Integer)
  645.     If Len(ThisControl.Text) = Length% Then
  646.       If KeyAscii <> 8 Then
  647.         KeyAscii = 0
  648.         Beep
  649.       End If
  650.     Else
  651.       C$ = Chr$(KeyAscii)
  652.       StringLength% = Len(ThisControl.Text)
  653.       DecimalPosition% = InStr(ThisControl.Text, ".")
  654.       If StringLength% - DecimalPosition% = 4 And DecimalPosition% <> 0 Then
  655.         If ThisControl.SelStart < DecimalPosition% Then
  656.           Select Case C$
  657.             Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  658.             Case "-"
  659.               If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  660.                 KeyAscii = 0
  661.                 Beep
  662.               End If
  663.             Case Else
  664.               KeyAscii = 0
  665.               Beep
  666.           End Select
  667.         ElseIf KeyAscii <> 8 Then
  668.           KeyAscii = 0
  669.           Beep
  670.         End If
  671.       Else
  672.         Select Case C$
  673.           Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
  674.           Case "."
  675.             If InStr(ThisControl.Text, ".") <> 0 Then
  676.               KeyAscii = 0
  677.               Beep
  678.             End If
  679.           Case "-"
  680.             If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
  681.               KeyAscii = 0
  682.               Beep
  683.             End If
  684.           Case Else
  685.             KeyAscii = 0
  686.             Beep
  687.         End Select
  688.       End If
  689.     End If
  690. End Sub
  691.  
  692. Function Point4LF# (ThisControl As Control, Min#, Max#)
  693.   Test# = Val(ThisControl.Text)
  694.   If ThisControl.Text <> "" Then
  695.     If Test# < Min# Or Test# > Max# Then
  696.       Beep
  697.       Msg$ = "Number must be between " + Str$(Min#) + " and " + Str$(Max#)
  698.       MsgBox Msg$, 0, "Warning"
  699.       ThisControl.SetFocus
  700.     Else
  701.       Point4LF# = Test#
  702.     End If
  703.   End If
  704. End Function
  705.  
  706.  
  707. Sub StrKP (ThisControl As Control, Length%, KeyAscii As Integer)
  708.     If Len(ThisControl.Text) = Length% Then
  709.       If KeyAscii <> 8 Then
  710.         KeyAscii = 0
  711.         Beep
  712.       End If
  713.     End If
  714. End Sub
  715.  
  716. Sub UCStrKP (ThisControl As Control, Length%, KeyAscii As Integer)
  717.     If Len(ThisControl.Text) = Length% Then
  718.       If KeyAscii <> 8 Then
  719.         KeyAscii = 0
  720.         Beep
  721.       End If
  722.     Else
  723.         KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
  724.     End If
  725. End Sub
  726.  
  727.